package cn.db101.jcc.controller;

import cn.db101.jcc.entity.Favorites;
import cn.db101.jcc.entity.Lineup;
import cn.db101.jcc.model.ResultModel;
import cn.db101.jcc.service.FavoritesService;
import cn.db101.jcc.service.LineupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zooy
 * @create 2024-06-11 1:40
 * @description
 */
@RestController
@RequestMapping("v1/jcc/favorites")
public class FavoritesController {

    @Autowired
    private FavoritesService favoritesService;

    @PostMapping("list")
    public ResultModel lineupList(@RequestBody Favorites favorites) {

        return ResultModel.success(favoritesService.lineUpList(favorites.getUserId()));
    }

    @PostMapping("add")
    public ResultModel add(@RequestBody Favorites favorites) {

        favoritesService.save(favorites);
        return ResultModel.success();
    }

    @PostMapping("delete")
    public ResultModel delete(@RequestBody Favorites favorites) {

        favoritesService.deleteFavorites(favorites);
        return ResultModel.success();
    }

    @PostMapping("one")
    public ResultModel one(@RequestBody Favorites favorites) {

        return ResultModel.success(favoritesService.selectOne(favorites));
    }

}
